﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;

namespace BIZMA.BL.Security
{
    public class BIZMAUser
    {
        public string UserName { get; set; }
        public Guid UserId { get; set; }
        public Guid AspNetUserId { get; set; }
        public BIZModel.UserProfile UserInfo { get; set; }
        public bool isSA { get; set; }
        public List<SystemFunction> SystemFunctions { get; set; }
    }

    public class SystemFunction
    {
        public string FunctionKey  { get; set; }
        public string ObjectType { get; set; }


        public SystemFunction(string functionKey, string objecktType)
        {
            FunctionKey = functionKey;
            ObjectType = objecktType;
        }
    }


    public sealed class UserHandler
    {
        private static SortedList<string, BIZMAUser> UserProfiles = new SortedList<string, BIZMAUser>();

        public static BIZMAUser GetUserProfile(string userName)
        {
            if(UserProfiles.ContainsKey(userName.ToLower()))
            return UserProfiles[userName.ToLower()];

            return null;
        }

        public static void ClearUserProfile(string userName)
        {
            UserProfiles.Remove(userName.ToLower());
        }

        public static void RefreshUserProfile(string userName, BIZMAUser userProfile)
        {
            ClearUserProfile(userName.ToLower());
            UserProfiles.Add(userName.ToLower(), userProfile);
        }
    }



}